//
//  JayInAppRageIAPHelper.m
//  ent
//
//  Created by Coffee on 15-5-28.
//  Copyright (c) 2015年 ND. All rights reserved.
//

#import "JayInAppRageIAPHelper.h"
#import "AppDelegate.h"


@implementation JayInAppRageIAPHelper

+ (instancetype)sharedHelper {
    static JayInAppRageIAPHelper *_sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedInstance = [[JayInAppRageIAPHelper alloc] init];
    });
    
    return _sharedInstance;
}

- (id)init {
    NSSet *productIdentifiers = [NSSet setWithObjects:
                                 @"com.jayandme.30flowers",
                                 @"com.jayandme.140flowers",
                                 @"com.jayandme.340flowers",
                                 @"com.jayandme.790flowers",
                                 @"com.jayandme.1440flowers",nil];
    
    if ((self = [super initWithProductIdentifiers:productIdentifiers])) {
    }
    return self;
}


- (void)sendTransaction:(SKPaymentTransaction *)transaction toServerWithParams:(NSDictionary*)params {
    NSLog(@"%s,params:%@",__func__,params);
    NSString *url = kNotifyPayRet;
    MUPRestRequestOperationManager * manager = [AppDelegate restDaoManager];
    [manager POST:url parameters:params beforeRequestHandler:nil class:nil success:^(MUPHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"%s,response:%@",__func__,responseObject);
        [self successNotifyServerAfterBuyProduct:transaction];
    } failure:^(MUPHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%s,error:%@",__func__,error);
    }];
}
@end
